package com.ltxtiyu.video.exception;

import com.ltxtiyu.video.common.JsonTool;
import com.ltxtiyu.video.common.RetEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 处理没有抓取到的异常
 */
@ControllerAdvice
public class LtxExceptionHandler {
    public static final Logger LOGGER = LoggerFactory.getLogger(LtxExceptionHandler.class);

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public String handleExceptionXX(Exception e, HttpServletRequest request){
        LOGGER.error(">>>>>>>>>>>发生错误,错误信息:{}",e);
        return JsonTool.genJson(RetEnum.RUNTIME_ERROR); // 40, 请刷新页面重试
    }
}
